{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model4.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}19 Oct 2017, 12:00:47
{txt}
{com}. 
. **** This code can be used to generate line a in Table 3 
. * "Average marginal effects of ideological proximity conditional
. *on the level of corruption, perceptual accuracy and political efficacy
. *and their 95% confidence intervals" in the article
. 
. ** The code has been generated based on Hanmer and Kalkan(2013) online Appendix
. * AJPS_602_sm_suppmatS1.docx available at 
. * http://onlinelibrary.wiley.com/doi/10.1111/j.1540-5907.2012.00602.x/abstract
. 
. * Hanmer, M. J. and K. O. Kalkan (2013). Behind the curve: Clarifying the best 
. * approach to calculating predicted probabilities and marginal effects from 
. * limited dependent variable models. American Journal of Political Science 57 (1),
. * 263–277
. 
. ***The measures for corruption should be purchased from the PRG Group. 
. *In this article, I used the monthy measures of corruption from Table 3b and 
. *calculated the annual averages:
. *forvalues i=1984/2016{c -(}
. *gen corruption`i'= _01_`i'+_02_`i'+ _03_`i'+_04_`i'+ _05_`i' + _06_`i'+ ///
> *_07_`i'+_08_`i'+ _09_`i'+_10_`i'+ _11_`i' + _12_`i'
. *{c )-}
. *drop Variable _01_1984 - _01_2017
. *reshape long corruption, i(Country) j(year)
. 
. ** These should be merged with the data. Make sure the variable is called corruption 
. 
. ** The dataset DOES NOT include a variable for corruption!!!
. 
. clear all
{txt}
{com}. 
. set mem 1000m
{txt}{bf:set memory} ignored.
{p 4 4 2}
Memory no longer
needs to be set in modern Statas;
memory adjustments are performed on the fly
automatically.
{p_end}

{com}. set maxvar 32767

{txt}
{com}. 
. set seed 99
{txt}
{com}. estimates use simple // See probit-models-of-vote-for-the-incumbent
{res}{txt}
{com}. 
. 
. mat b=e(b)
{txt}
{com}. mat V=e(V)
{txt}
{com}. 
. drawnorm corruption_b ideolcor_b ideolprime_b  ///
> age_b male_b income_b loweducation_b higheducation_b unemployed_b retired_b  ///
> other_b partisan_b gdp_b durable_b partyage_b pr_b pluralty_b mdmh_b  ///
> p_effnv_b  p_maj_b  state_b east_b noneuro_b  system_b growth_b  ///
> cons_b, mean(b) cov(V) n(1000)
{txt}(obs 1,000)

{com}.   
. merge using recoded_CSES_data.dta
{txt}{p}
(note: you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}

{com}. 
. 
. 
. // calculate the marginal effect of ideological proximity when corruption is 
. // low (0.1) and high (0.8)
. 
. foreach j of numlist 1 8 {c -(} 
{txt}  2{com}.  
.  gen eff_ideol_`j'=.
{txt}  3{com}. 
.  replace corruption=`j'/10 // corruption is either 0.1 or 0.8
{txt}  4{com}. 
.  // run 1000 simulations
.  
.  quietly  forvalues i=1/1000{c -(}
{txt}  5{com}.   gen p_`i'=normalden(corruption_b[`i']*corruption +  ///
> ideolcor_b[`i']*ideolprime*corruption + ideolprime_b[`i']*ideolprime + /// 
> age_b[`i']*age + male_b[`i']*male + income_b[`i']*income + ///
>  loweducation_b[`i']*loweducation + higheducation_b[`i']*higheducation +  ///
> unemployed_b[`i']*unemployed + retired_b[`i']*retired + other_b[`i']*other + ///
>  partisan_b[`i']*partisan + gdp_b[`i']*gdp + durable_b[`i']*durable + ///
>  partyage_b[`i']*partyage + pr_b[`i']*pr + pluralty_b[`i']*pluralty + ///
> mdmh_b[`i']*mdmh +  p_effnv_b[`i']*p_effnv +   p_maj_b[`i']*p_maj + ///
>  state_b[`i']*state_b + east_b[`i']*east + noneuro_b[`i']*noneuro + ///
>  system_b[`i']*system + growth_b[`i']*growth + ///
> cons_b[`i'])*(ideolcor_b[`i']*corruption+ ideolprime_b[`i'])
{txt}  6{com}.  
.  sum p_`i', meanonly
{txt}  7{com}.  
.  replace eff_ideol_`j'=r(mean) in `i'
{txt}  8{com}.  {c )-}
{txt}  9{com}.  drop p_1-p_1000
{txt} 10{com}.  
.   {c )-}  
{txt}(66,987 missing values generated)
(60,665 real changes made)
(66,987 missing values generated)
(66,987 real changes made)

{com}.   
.   gen effect=. // estimate
{txt}(66,987 missing values generated)

{com}.   gen effect_l=.  // low value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  gen effect_u=. // high value of 95% confidence intervals
{txt}(66,987 missing values generated)

{com}.  
.   
. foreach k of numlist  1 8 {c -(}
{txt}  2{com}.  sum eff_ideol_`k', meanonly
{txt}  3{com}.  replace effect=r(mean) in `k'
{txt}  4{com}.  centile eff_ideol_`k', centile(2.5)
{txt}  5{com}.   replace effect_l=r(c_1) in `k'
{txt}  6{com}.  centile eff_ideol_`k', centile(97.5)
{txt}  7{com}.   replace effect_u=r(c_1) in `k'
{txt}  8{com}.   {c )-}
{txt}(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
 eff_ideol_1 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0010043{col 55} .0004551{col 67} .0016497{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
 eff_ideol_1 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0499593{col 55}  .048421{col 67} .0516047{txt}
(1 real change made)
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
 eff_ideol_8 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0003038{col 55} .0001732{col 67}  .000544{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
 eff_ideol_8 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0333188{col 55} .0319266{col 67} .0352583{txt}
(1 real change made)

{com}. 
.   // marginal effect of ideological voting in low corruption countries:
.   list effect effect_l effect_u in 1
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}  effect   effect_l   effect_u {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
  1. {c |} {res}.0280276   .0010043   .0499593 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
.   //marginal effect of ideological voting in high corruption countries:
.     list effect effect_l effect_u in 8
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}  effect   effect_l   effect_u {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
  8. {c |} {res}.0174421   .0003038   .0333188 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}.         
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model4.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}19 Oct 2017, 12:03:12
{txt}{.-}
{smcl}
{txt}{sf}{ul off}